import { BigNumber } from "bignumber.js/bignumber";

export default {
  // X
  multi(x: string, y: string) {
    return new BigNumber(x).multipliedBy(new BigNumber(y)).toPrecision();
  },
  // +
  plus(x: string, y: string) {
    return new BigNumber(x).plus(new BigNumber(y)).toPrecision();
  },
  // -
  minus(x: string, y: string) {
    return new BigNumber(x).minus(new BigNumber(y)).toPrecision();
  },
  // \
  div(x: string, y: string) {
    return new BigNumber(x).div(new BigNumber(y)).toPrecision();
  },
  // ==
  isEq(x: string, y: string) {
    return new BigNumber(x).isEqualTo(new BigNumber(y));
  },
  // >
  isGt(x: string, y: string) {
    return new BigNumber(x).isGreaterThan(new BigNumber(y));
  },
  // >=
  isGtOrEq(x: string, y: string) {
    return new BigNumber(x).isGreaterThanOrEqualTo(new BigNumber(y));
  },
  // <
  isLt(x: string, y: string) {
    return new BigNumber(x).isLessThan(new BigNumber(y));
  },
  // <=
  isLtOrEq(x: string, y: string) {
    return new BigNumber(x).isLessThanOrEqualTo(new BigNumber(y));
  },
  // 是负数？
  isN(x: string) {
    return new BigNumber(x).isNegative();
  },
  // 是正数？
  isP(x: string) {
    return new BigNumber(x).isPositive();
  },
  // 是 0 ？
  isZ(x: string) {
    return new BigNumber(x).isZero();
  },
  toFixed(x: string, y: number) {
    return new BigNumber(x).toFixed(+y, 1);
  },
  toFixed8(x: string) {
    return new BigNumber(x).toFixed(8, 1);
  },
  toFixed2(x: string) {
    return new BigNumber(x).toFixed(2, 1);
  },
  toFixed0(x: string) {
    return new BigNumber(x).toFixed(0, 1);
  },
  BigNumber(x: string) {
    return new BigNumber(x);
  },
  Number(x: string) {
    return Number(x);
  }
};
